/**
 * 
 */
package com.vector.ding.platform;

import java.sql.SQLException;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.vector.ding.commons.util.spring.SpringUtil;
import com.vector.ding.context.WebContext;
import com.vector.ding.exception.BaseException;

/**
 * 系统引擎
 * @author vector
 *
 */
@Component
public class Engine implements ApplicationContextAware {

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		// XML中bean已经加加载完定义, 执行对组件的初始化
		initComponents();
	}

	public void initComponents() {
		// 初始化数据源
		//initDataSource();
		WebContext.getMenuEntities();
	}
	
	@SuppressWarnings("unused")
	private void initDataSource() {
		ComboPooledDataSource poolDs = SpringUtil.getBean(ComboPooledDataSource.class);
		try {
			poolDs.getConnection();
		} catch (SQLException e) {
			e.printStackTrace();
			throw new BaseException(e);
		}
	}

}
